Longitudinal electronic health record analysis